package com.sfzlot.dev.netty.bean.identifier;

/**
 * Created by ASUS on 2017/5/27.
 * 应答标识
 */
public enum ResponseIdentifier {
    SUCCESS(0x01),
    ERROR(0x02),
    VIN_REPEATED(0x03),
    COMMAND(0xFE);

    private int code;
    ResponseIdentifier(int code){
        this.code = code;
    }

    public int getCode() {
		return code;
	}

	/**
     * 获取应答标识
     * @param code
     * @return
     */
    public static ResponseIdentifier getResponseIdentifier(int code){
        for (ResponseIdentifier responseIdentifier : ResponseIdentifier.values()) {
            if (responseIdentifier.code == code){
                return responseIdentifier;
            }
        }
        throw new IllegalArgumentException();
    }
    
    /**
     * 根据码获取应答标识对应的备注
     * 
     */
    public static String getResponseIdentifier(ResponseIdentifier responseIdentifier){
    	switch (responseIdentifier) {
			case SUCCESS:return "成功";
			case ERROR:return "失败";
			case VIN_REPEATED:return "设备码重复";
			case COMMAND:return "指令";
		default:
			break;
    	}
		return null;
    }
}
